package com.xcjh.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") // 要拦截的请求
                .excludePathPatterns(
                        "/LoginInfo/**",
                        "/User/register",
                        "/User/getBackPasswordPhone",
                        "/User/getBackPasswordEmail",
                        "/User/uploadHead",
                        "/Verifycode/**") // 要放行的请求
                .excludePathPatterns("/swagger-resources/**","/webjars/**","/v2/**","/swagger-ui.html/**");
                // 放行swagger所有资源
    }
}
